﻿using B.S.Sterilizationcenter.Domain.zmc;
using B.S.Sterilizationcenter.ErrorCode;
using B.S.Sterilizationcenter.Read.API.Appliaction.Commends.zmc.Outbounds;
using MediatR;
using SqlSugar;

namespace B.S.Sterilizationcenter.Read.API.Appliaction.CommandHandlers.zmc.Outbounds
{
    public class QueryOutboundTypeCommendHandlers : IRequestHandler<QueryOutboundTypeCommends, ApiResult<List<OutboundType>>>
    {
        private readonly ISqlSugarClient db;

        public QueryOutboundTypeCommendHandlers(ISqlSugarClient db)
        {
            this.db = db;
        }

        /// <summary>
        /// 查询出库类型
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<ApiResult<List<OutboundType>>> Handle(QueryOutboundTypeCommends request, CancellationToken cancellationToken)
        {
            ApiResult<List<OutboundType>> result = new ApiResult<List<OutboundType>>();
            result.Code = ApiEnums.查询成功;
            result.Msg= "查询成功";
            var list = db.Queryable<OutboundType>().ToList();
            result.Data = list;
            return result;
        }
    }
}
